package com.yangcangclub.api.v1.system.controller;


import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;


/**
 * 系统生命仪
 */
@Controller
public class HelloController {
    @Autowired
    RedisTemplate redisTemplate;
    private static  String startTime;

    @PostConstruct
    public void init(){
        startTime= DateTime.now().toString("yyyy-MM-dd HH:mm");
    }
    @ResponseBody
    @RequestMapping(value = "/yangcangclub/v1/hello")
    public String hello() {

    
        
        //测试下redis
        BoundValueOperations vo=redisTemplate.boundValueOps("system_yangcangclub_alive_test");
        vo.set("Hello, I'm still alive ..."+startTime,10, TimeUnit.SECONDS);
        return (String)vo.get();
    }

}